// pages/bill/info/index.js
const App = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userBillInfo:{},
    inputNameValue:'',
    inputMobileValue:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getUserDetail()
  },
  /**
   * 查询用户账单
   */
  getUserDetail() {
    let _this = this;
    App._get('user/getJiangPin', {}, function(result) {
      _this.setData(result.data);
    });
  },
  bindNameInput: function (e) {
    this.setData({
      inputNameValue: e.detail.value
    })
  },
  bindMobileInput: function (e) {
    this.setData({
      inputMobileValue: e.detail.value
    })
  },
  lingjiang(){
    let _this = this
    if(_this.data.inputNameValue == ''){
      App.showError('请输入领奖人姓名！')
      return false
    }
    if(_this.data.inputMobileValue == ''){
      App.showError('请输入领奖人手机号！')
      return false
    }
    App._post_form('user/lingjiang', {
      id: _this.data.userBillInfo.id,
      username: _this.data.inputNameValue,
      mobile: _this.data.inputMobileValue,
    }, result => {
      App.showSuccess(result.data,function(){
        _this.getUserDetail()
      })
    }, false, () => {
      wx.hideLoading();
    });
  }
})